import Vue from 'vue'
import Vuex from 'vuex'
import Cookies from 'js-cookie'

// 全局store
import getters from './getters'
import actions from './actions'
import mutations from './mutations'

// 导入子模块store
import common from './modules/common'
import session from './modules/session'
import taskTemplate from './modules/taskTemplate'
import score from './modules/score'
Vue.use(Vuex);

let is_sso_saml = process.env.SSO_TYPE === 'saml' ? true : false

const state = {
  language: Cookies.get('language') || 'cn',
  is_sso_saml: is_sso_saml,
  ssourl: is_sso_saml 
    ? process.env.SSO_ROOT_SAML + '/login'
    : process.env.SSO_ROOT + '/loginIn',
  ssologout: is_sso_saml 
    ? process.env.SSO_ROOT_SAML + '/Logout'
    : process.env.SSO_ROOT + '/revoking' 
}

const store = new Vuex.Store({
  state,
  getters,
  actions,
  mutations,
  modules: {
    common,
    session,
    taskTemplate,
    score
  }
});

export default store;
